Add gtk_button_new_from_icon_name
authorYosef Or Boczko <yoseforb@gmail.com>
Wed, 14 Aug 2013 07:41:42 +0000 (10:41 +0300)
committerYosef Or Boczko <yoseforb@gmail.com>
Wed, 14 Aug 2013 07:41:42 +0000 (10:41 +0300)
This function is a convenience wrapper around
gtk_button_new() and gtk_button_set_image().

https://bugzilla.gnome.org/show_bug.cgi?id=705918

Signed-off-by: Yosef Or Boczko <yoseforb@gmail.com>
docs/reference/gtk/gtk3-sections.txt
gtk/gtkbutton.c
gtk/gtkbutton.h

index 9da9adaebd988a8af2748011249078deb865187d..affd74313e2c25840521fccc3ca4fc16b96f7fe4 100644 (file)
@@ -636,6 +636,7 @@ GtkButton
 gtk_button_new
 gtk_button_new_with_label
 gtk_button_new_with_mnemonic
+gtk_button_new_from_icon_name
 gtk_button_new_from_stock
 gtk_button_pressed
 gtk_button_released
index 7396cb8addf5df3fdc8dbaf393336830c587c2cc..3074e7e1ebc337a898260afcceda6e17d51c10a9 100644 (file)
@@ -1297,6 +1297,42 @@ gtk_button_new_with_label (const gchar *label)
   return g_object_new (GTK_TYPE_BUTTON, "label", label, NULL);
 }
 
+/**
+ * gtk_button_new_from_icon_name:
+ * @icon_name: an icon name
+ * @size: (type int): an icon size
+ *
+ * Creates a new #GtkButton containing an icon from the current icon theme.
+ * 
+ * If the icon name isn't known, a "broken image" icon will be
+ * displayed instead. If the current icon theme is changed, the icon
+ * will be updated appropriately.
+ * 
+ * This function is a convenience wrapper around gtk_button_new() and
+ * gtk_button_set_image().
+ * 
+ * Returns: a new #GtkButton displaying the themed icon
+ * 
+ * Since: 3.10
+ **/
+GtkWidget*
+gtk_button_new_from_icon_name (const gchar *icon_name,
+                              GtkIconSize  size)
+{
+  GtkStyleContext *context;
+  GtkWidget *button;
+  GtkWidget *image;
+
+  image = gtk_image_new_from_icon_name (icon_name, size);
+  button =  g_object_new (GTK_TYPE_BUTTON,
+                         "image", image,
+                         NULL);
+  context = gtk_widget_get_style_context (button);
+  gtk_style_context_add_class (context, "image-button"));
+
+  return button;
+}
+
 /**
  * gtk_button_new_from_stock:
  * @stock_id: the name of the stock item 
index 7c319942510f29e7644ce4b89e7d3faca076aef3..18379889fa6484747550fa8217d9e219d2a09a2c 100644 (file)
@@ -80,6 +80,9 @@ GDK_AVAILABLE_IN_ALL
 GtkWidget*     gtk_button_new               (void);
 GDK_AVAILABLE_IN_ALL
 GtkWidget*     gtk_button_new_with_label    (const gchar    *label);
+GDK_AVAILABLE_IN_3_10
+GtkWidget*     gtk_button_new_from_icon_name (const gchar    *icon_name,
+                                             GtkIconSize     size);
 GDK_DEPRECATED_IN_3_10_FOR(gtk_button_new_with_label)
 GtkWidget*     gtk_button_new_from_stock    (const gchar    *stock_id);
 GDK_AVAILABLE_IN_ALL